package com.gsy.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;


import java.sql.Timestamp;
import java.util.Date;

@Component
public class MybatisDataUpdata implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("createtime", new Timestamp(System.currentTimeMillis()),metaObject);
        this.setFieldValByName("createTime", new Timestamp(System.currentTimeMillis()),metaObject);
        this.setFieldValByName("modifytime",new Timestamp(System.currentTimeMillis()), metaObject);
        this.setFieldValByName("readtime",new Timestamp(System.currentTimeMillis()), metaObject);
        this.setFieldValByName("isDeleted",'0', metaObject);
        this.setFieldValByName("isDisable",'0', metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("modifytime",new Timestamp(System.currentTimeMillis()), metaObject);
    }

}
